#include "cc_workqueue.h"
#include "cc_log.h"

#if (CC_CONFIG_TEST_WORKQUEUE == 1)

struct cc_workqueue* my_workqueue;
struct cc_work work1;
struct cc_work work2;
struct cc_work work3;
int cnt;
void work_func1(struct cc_work* work, void* work_data)
{
  cc_log("Work Fun Success1\r\n");
}
void work_func2(struct cc_work* work, void* work_data)
{
  cnt++;
  cc_work_submit(&work2, 5000);
  cc_log("Work Fun Success2:%d\r\n", cnt);
  return;
}
void work_func3(struct cc_work* work, void* work_data)
{
  cc_log("Work Fun Success3\r\n");
}

void test_workqueue(void* data)
{
  cc_log("Test workqueue\r\n");
  cc_work_init(&work1, work_func1, CC_NULL);
  cc_work_init(&work2, work_func2, CC_NULL);
  cc_work_init(&work3, work_func3, CC_NULL);
  my_workqueue = cc_workqueue_create("test", 2048, 10);
  cc_workqueue_submit_work(my_workqueue, &work3, 5000);

  cc_work_submit(&work1, 5000);
  cc_work_submit(&work2, 5000);
  while (1)
  {

    cc_sleep(5);
  }
}
CC_THREAD_REGISTER(test_workqueue, 32, 2048);

#endif